class Solution
{
public:
    int findTargetNode(TreeNode* root, int cnt)
    {
        this->cnt = cnt;
        dfs(root);

        return res;
    }
private:
    int res, cnt;
    void dfs(TreeNode* root)
    {
        if (root == nullptr) return;

        dfs(root->right);

        if (cnt == 0) return;

        if (--cnt == 0)
            res = root->val;

        dfs(root->left);
    }
};